$(document).on('pageinit', function(){
	//判断是否微信浏览器
	var useragent = navigator.userAgent.toLowerCase();
	if(useragent.match(/MicroMessenger/i) != "micromessenger"){
		//window.location.href = '../index.html';
	}
});

var showLoader = function() {  
    //显示加载器.for jQuery Mobile 1.2.0  
    $.mobile.loading('show', {  
        text: '加载中...', //加载器中显示的文字  
        textVisible: true, //是否显示文字  
        theme: 'a',        //加载器主题样式a-e  
        textonly: false,   //是否只显示文字  
        html: ""           //要显示的html内容，如图片等  
    });  
}  
  
//隐藏加载器.for jQuery Mobile 1.2.0  
var hideLoader = function()  
{  
    //隐藏加载器  
    $.mobile.loading('hide');  
}

$(document).on("click", ".show-page-loading-msg", function() {
	var $this = $( this ),
		theme = $this.jqmData("theme") || $.mobile.loader.prototype.options.theme,
		msgText = $this.jqmData("msgtext") || $.mobile.loader.prototype.options.text,
		textVisible = $this.jqmData("textvisible") || $.mobile.loader.prototype.options.textVisible,
		textonly = !!$this.jqmData("textonly");
		html = $this.jqmData("html") || "";
	$.mobile.loading( 'show', {
			text: msgText,
			textVisible: textVisible,
			theme: theme,
			textonly: textonly,
			html: html
	});
})
.on("click", ".hide-page-loading-msg", function() {
	$.mobile.loading( 'hide' );
});

var setCookie = function(name,value){//两个参数，一个是cookie的名子，一个是值
	var Days = 30; //此 cookie 将被保存 30 天
	var exp  = new Date();
	exp.setTime(exp.getTime() + Days*24*60*60*1000);
	document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
}

var getCookie = function(name){//取cookies函数       
	var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
	 if(arr != null) return (arr[2]); return null;
}

var delCookie = function(name){//删除cookie
	var exp = new Date();
	exp.setTime(exp.getTime() - 1);
	var cval=getCookie(name);
	if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString();
}

wx.ready(function(){
	wx.hideOptionMenu();
});